import {
  IsNotEmpty,
  IsString,
  IsNumber,
  IsBoolean,
  IsOptional,
  IsIn,
} from 'class-validator';

export class validatePostBodyDto {
  @IsNotEmpty({ message: 'Title is required' }) // 必填,不为空
  @IsString({ message: 'Title must be a string' })
  readonly title: string;

  @IsNotEmpty({ message: 'Price is required' })
  @IsNumber({}, { message: 'Price must be a number' })
  readonly price: number;

  @IsOptional() // 可选
  @IsBoolean({ message: 'IsPublished must be a boolean' })
  readonly isPublished: boolean;

  @IsNotEmpty({ message: 'Sex is required' })
  @IsString({ message: 'Sex must be a string' })
  @IsIn(['男', '女'], { message: 'sex must be one of [男, 女]' }) //参数值只能是数组中的其中一位成员
  readonly sex: string;
}

export interface sseCustomMessageQuery {
  username: string;
  age: string;
}
